home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.internetmci.com!xmission!inteleNET!usenet
- From: langj@jcave.com (Jonathan Lang)
- Newsgroups: comp.lang.c++,comp.sys.sgi.misc
- Subject: Re: What is the best way to initialize static template members?
- Date: Sat, 09 Mar 1996 00:24:47 GMT
- Organization: inteleNET Internet Services
- Message-ID: <4hqfh0$lid@vodka.intele.net>
- References: <313799EF.41C6@mozart.nmrcore.uab.edu> <313AAA8D.41C6@rus.uni-stuttgart.de> <4ho162$io5@vodka.intele.net>
- NNTP-Posting-Host: p142.jcave.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- langj@jcave.com (Jonathan Lang) wrote:
-
- >Andreas Wierse <wierse@rus.uni-stuttgart.de> wrote:
-
- >>Hunter Moseley wrote:
- >>>
- >>> What is the best way to initialize static template members?
- >>>
- >>> Example:
- >>>
- >>> template<class T>
- >>> class X
- >>> {
- >>> private :
- >>> static int min_buff_size;
- >>> ...
- >>> };
- >>>
- >>> What is the best way to initialize min_buff_size for a given
- >>> X<T> class?
-
- >>I don't know what's the best way, but I know what works for me :-).
-
- >>I maintain a library and all static member initialization takes place
- >>in a file named ec_statics.C. One line for example looks like the
- >>following:
-
- >>List<MMapEntry> *Malloc_tmp::mmaplist = new List<MMapEntry>;
-
- >>Applied to your case this would look like:
-
- >>X<T> X::min_buff_size = 100;
-
- >>Note, that in my case even the static variable that is initialized
- >>depends on the template.
-
- >>I use C++ 4.0 under IRIX 5.3 on my Indigo.
-
- >>You can read more about this in the ARM, section 9.4, pp. 179-181.
-
- >First, wouldn't this be:
-
- >int X<T>::min_buff_size = 100;
-
- >?
-
- Actually, I think it should be
-
- template <class T> int X<T>::min_buff_size = 100;
-
- except that it can't be done that way (there are no template objects;
- just template classes and template functions); so, how would you do
- this?
- -- Jonathan Lang (langj@jcave.com)
-
-